# shop=[
#     ["回锅肉",100],
#     ["小鸡炖蘑菇",70],
#     ["红烧肉",80],
#     ["鱼香肉丝",40],
#     ["酸菜鱼",130],
#     ["馋嘴牛蛙",130],
#     ["劲爆鸡脆骨",80],
#     ["蒜蓉粉丝蒸生蚝",60],
#     ["酸辣丸子汤",30],
#     ["炒面",15],
#     ["米饭",2]
# ]
# car=[]
# money=1000
# while True:
#     for i,y in enumerate(shop):
#         print(i,y)
#     buy=input("请输入商品编号")
#     if buy.isdigit():
#         buy=int(buy)
#         if 0<=buy<len(shop):
#             if money>=shop[buy][1]:
#                 car.append(shop[buy])
#                 money=money-shop[buy][1]
#                 print("您的商品已添加到购物车，剩余金额为{}".format(money))
#             else:
#                 print("余额不足")
#         else:
#             print("您输入的商品有误")
#     elif buy=="q" or buy=="Q":
#         print("欢迎下次光临，以下是您的小票")
#         for i,y in enumerate(car):
#             print(i, y)
#         break
#     else:
#         print("您输入的商品有误")
shop=[
    ["回锅肉",100],
    ["小鸡炖蘑菇",70],
    ["红烧肉",80],
    ["鱼香肉丝",40],
    ["酸菜鱼",130],
    ["馋嘴牛蛙",130],
    ["劲爆鸡脆骨",80],
    ["蒜蓉粉丝蒸生蚝",60],
    ["酸辣丸子汤",30],
    ["炒面",15],
    ["米饭",2]
]
car=[]
money=1000
import random
ran=random.randint(1,2)
print(ran)
if ran==1:
    print("回锅肉打八折")
    hui=5
else:
    print("小鸡炖蘑菇打九折")
    xiao=10
while True:
    for i,y in enumerate(shop):
        print(i,y)
    buy=input("请输入商品号")
    if buy.isdigit():
        buy=int(buy)
        if 0<=buy<len(shop):
            if money>shop[buy][1]:
                car.append(shop[buy])
                if ran==1 and buy==0 and hui>0:
                    money=money-shop[0][1]*0.8
                    hui=hui-1
                elif ran==2 and buy==1 and xiao>0:
                    money=money-shop[1][1]*0.9
                    xiao=xiao-1
                else:
                    money=money-shop[buy][1]
                print("您的商品已添加到购物车，余额为",money)
            else:
                print("余额不足")
        else:
            print("输入有误")
    elif buy=="q" or buy=="Q":
        print("以下是您的小票，欢迎下次光临")
        for i,y in enumerate(car):
            print(i,y)
        money+=((1000-money)//200)*10
        print("您的余额为",money)
        break
    else:
        print("输入商品有误")
